package com.lc.luzhengtang.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lc.luzhengtang.BaseApplication;
import com.lc.luzhengtang.R;
import com.lc.luzhengtang.base.BaseActivity;
import com.lc.luzhengtang.bean.MyWalletBean;
import com.lc.luzhengtang.conn.ConnMyWallet;
import com.zcx.helper.http.AsyCallBack;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.lc.luzhengtang.R.id.text_money_detail;

/**
 * Created by Administrator on 2017/5/5.
 */
public class MyWalletActivity extends BaseActivity {

    @BindView(R.id.img_news)
    ImageView imgNews;
    @BindView(R.id.textView)
    TextView textView;
    @BindView(R.id.text_money_all)
    TextView textMoneyAll;
    @BindView(R.id.img_dianpu)
    ImageView imgDianpu;
    @BindView(R.id.text_jifen)
    TextView textJifen;
    @BindView(text_money_detail)
    TextView textMoneyDetail;
    @BindView(R.id.layout_dianpu)
    RelativeLayout layoutDianpu;
    @BindView(R.id.img_shouyi)
    ImageView imgShouyi;
    @BindView(R.id.layout_shouyi)
    RelativeLayout layoutShouyi;
    @BindView(R.id.img_weijine)
    ImageView imgWeijine;
    @BindView(R.id.text_nomoney)
    TextView textNomoney;
    @BindView(R.id.text_nomoney_weijie)
    TextView textNomoneyWeijie;
    @BindView(R.id.layout_nolimit_money)
    RelativeLayout layoutNolimitMoney;
    @BindView(R.id.img_yijiesun)
    ImageView imgYijiesun;
    @BindView(R.id.text_already_money)
    TextView textAlreadyMoney;
    @BindView(R.id.text_arready_money)
    TextView textArreadyMoney;
    @BindView(R.id.layout_alreadylimit_money)
    RelativeLayout layoutAlreadylimitMoney;
    @BindView(R.id.btn_withdraw)
    Button btnWithdraw;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mywallet);
        ButterKnife.bind(this);

    }


    @Override
    protected void onResume() {
        super.onResume();
        getMyWalletData();
    }

    public void getMyWalletData() {
        new ConnMyWallet(BaseApplication.basePreferences.readUid(), new AsyCallBack<MyWalletBean>() {
            @Override
            public void onStart(int type) throws Exception {
                super.onStart(type);
                showLoading();
            }

            @Override
            public void onSuccess(String toast, int type, Object o, MyWalletBean myWalletBean) throws Exception {
                super.onSuccess(toast, type, o, myWalletBean);
                textMoneyAll.setText(myWalletBean.getData().getBalance());
//                text_money_detail
                textMoneyDetail.setText("￥"+myWalletBean.getData().getIntegral());
                //未结算金额text_nomoney_weijie  text_arready_money
                textNomoneyWeijie.setText("￥"+myWalletBean.getData().getReward() + "");
                textArreadyMoney.setText("￥"+myWalletBean.getData().getRewards() + "");

            }

            @Override
            public void onFail(String toast, int type) throws Exception {
                super.onFail(toast, type);
                dismissLoading();
            }

            @Override
            public void onEnd(String toast, int type) throws Exception {
                super.onEnd(toast, type);
                dismissLoading();
            }
        }


        ).execute(MyWalletActivity.this, false);
    }


    @OnClick({R.id.img_news, R.id.textView, R.id.text_money_all, R.id.img_dianpu, R.id.text_jifen, text_money_detail, R.id.layout_dianpu, R.id.img_shouyi, R.id.layout_shouyi, R.id.img_weijine, R.id.text_nomoney, R.id.text_nomoney_weijie, R.id.layout_nolimit_money, R.id.img_yijiesun, R.id.text_already_money, R.id.text_arready_money, R.id.layout_alreadylimit_money, R.id.btn_withdraw})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_news:
                finish();
                break;
            case R.id.textView:
                break;
            case R.id.text_money_all:
                break;
            case R.id.img_dianpu:
                break;
            case R.id.text_jifen:
                break;
            case text_money_detail:
                break;
            case R.id.layout_dianpu:
                startActivity(new Intent(MyWalletActivity.this, MyScoreActivity.class));

                break;
            case R.id.img_shouyi:
                break;
            case R.id.layout_shouyi:
                //跳转到优惠券
                startActivity(new Intent(MyWalletActivity.this, CouponActivity.class));

                break;
            case R.id.img_weijine:
                startActivity(new Intent(MyWalletActivity.this, UnsettledActivity.class));
                break;
            case R.id.text_nomoney:
                startActivity(new Intent(MyWalletActivity.this, UnsettledActivity.class));
                break;
            case R.id.text_nomoney_weijie:
                startActivity(new Intent(MyWalletActivity.this, UnsettledActivity.class));
                break;
            case R.id.layout_nolimit_money:
                startActivity(new Intent(MyWalletActivity.this, UnsettledActivity.class));


                break;
            case R.id.img_yijiesun:
                startActivity(new Intent(MyWalletActivity.this, AlreadySettled.class));
                break;
            case R.id.text_already_money:
                break;
            case R.id.text_arready_money:
                startActivity(new Intent(MyWalletActivity.this, AlreadySettled.class));
                break;
            case R.id.layout_alreadylimit_money:
                startActivity(new Intent(MyWalletActivity.this, AlreadySettled.class));

                break;

            case R.id.btn_withdraw:
                startActivity(new Intent(MyWalletActivity.this, WithDrawActivity.class));

                break;
        }
    }


}
